import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Game {
    //牌的花色只有四种，所以用static final来限制
    private static final String[] suits = {"♥","♠","♣","♦"};
    //生成扑克牌
    public List<Poker> mypokers(){
        //用顺序表来存放52张牌
        List<Poker> pokers = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= 13; j++) {
                //设置牌面数字
                int pokernumber = j;
                //往顺序表中添加牌
                Poker poker = new Poker(suits[i], pokernumber);
                pokers.add(poker);
            }
        }
        return pokers;
    }
    //洗牌
    public void  shuffle(List<Poker> pokerList){
        for (int i = pokerList.size() - 1; i > 0; i--) {
            Random random = new Random();
            //利用随机数随机生成一个下标和i位置进行交换完成洗牌
            int index = random.nextInt(i);
            swap(pokerList,i,index);
        }
    }
    //洗牌方法
    private void swap(List<Poker> pokerList,int i,int j){
        Poker tmp = pokerList.get(i);
        pokerList.set(i,pokerList.get(j));
        pokerList.set(j,tmp);
    }
    //三个人揭牌，每个人轮流揭5张牌
    public List<List<Poker>> unveiling(List<Poker> pokerList){
        List<List<Poker>> player = new ArrayList<>();
        List<Poker> player1 = new ArrayList<>();
        List<Poker> player2 = new ArrayList<>();
        List<Poker> player3 = new ArrayList<>();
        player.add(player1);
        player.add(player2);
        player.add(player3);
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Poker ret = pokerList.remove(0);
                player.get(j).add(ret);
            }
        }
        return player;
    }

}
